package ca.cbc.msb.entity;

import java.io.Serializable;

import ca.cbc.msb.enums.NotificationType;

public class MSBNotification implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = -7871504330415876106L;
	private long id;
	private String method;
	private NotificationType type;
	private long releaseId;
	private long mediaId;
	
	public long getId() {
		return id;
	}
	public void setId(long id) {
		this.id = id;
	}
	public String getMethod() {
		return method;
	}
	public void setMethod(String method) {
		this.method = method.toLowerCase().trim();
	}
	public NotificationType getType() {
		return type;
	}
	public void setType(NotificationType type) {
		this.type = type;
	}
	public void setType(String methodStr, String typeStr){
		methodStr = methodStr.toLowerCase().trim();
		typeStr = typeStr.toLowerCase().trim();
		
		if(methodStr.equals("post") && typeStr.equals("release"))
			this.type = NotificationType.NewRelease;
		else if(methodStr.equals("put") && typeStr.equals("release"))
			this.type = NotificationType.ChangedMedia;
		else if (methodStr.equals("delete") && typeStr.equals("release"))
			this.type = NotificationType.DeletedRelease;
		else
			this.type = NotificationType.Unknown;
	}
	public long getReleaseId() {
		return releaseId;
	}
	public void setReleaseId(long releaseId) {
		this.releaseId = releaseId;
	}
	public long getMediaId() {
		return mediaId;
	}
	public void setMediaId(long mediaId) {
		this.mediaId = mediaId;
	}
	@Override
	public String toString() {
		return "id(" + this.getId() + "); method(" + this.getMethod() + "); type(" + this.getType() + "); releaseId(" + this.getReleaseId() + "); mediaId(" + this.getMediaId()+")";
	}
}
